#include "worker.h"

#include <QDebug>
#include <QThread>

Worker::Worker(QObject *parent) : QObject{parent} {
    connect(this, &Worker::msg1, this, &Worker::msg1Slot);
}

void Worker::workSlot() {
    qDebug() << "QThread begin";
    qDebug() << "child thread id" << QThread::currentThreadId();
    qDebug() << "QThread end";

    // 线槽函数已经执行完进入线程exec()中，可以通过发射信号重新让槽函数在线程中执行。也可以通过
    // quit() 退出线程exec()。
}

void Worker::msg1Slot(const QString &m1) {
    qDebug() << QThread::currentThreadId() << "receive msg1 " << m1;
}

void Worker::msg3Slot(const QString &m3) {
    qDebug() << QThread::currentThreadId() << "receive msg3 " << m3;
}
